#include <regx52.h>
#include "Delay.h"
#include "LCD1602.h"
#include "Matrixkey.h"
unsigned char KeyNum;

void main()
{
	unsigned char Num;
	LCD_Init();
	while(1)
	{
		LCD_ShowNum(1,1,Num,5);
	}
	unsigned int password=0;
	unsigned char Count = 0;
	LCD_Init();
	LCD_ShowString(1,1,"password:");
	while(1)
	{
		
		KeyNum=Matrixkey();
		if(KeyNum)
		{
			if(KeyNum<=10)
				{
					
					if(Count<4)
						{
							password*=10;
							password+=KeyNum%10;
							LCD_ShowNum(2,2,password,4);
						}
					Count++;
				}
			if(KeyNum==11)
				{
					if(password==2345)
						{
							LCD_ShowString(1,14,"OK ");
						}
					else
						{
							LCD_ShowString(1,14,"ERR");
						}
				}
			if(KeyNum==12)
				{
					password=0;
					Count = 0;
					LCD_ShowNum(2,2,password,4);
					LCD_ShowString(1,14,"   ");
				}
			
		}
		
	}
}
